package com.lzh.healthCode.business.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.lzh.healthCode.business.entity.CjInfoBean;
import com.lzh.healthCode.business.entity.UpdParams;
import com.lzh.healthCode.business.mapper.CjInfoMapper;
import com.lzh.healthCode.business.service.CjInfoService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.List;

/**
 * @author suYanLong
 * @date 2022年07月11日 14:19
 */
@Slf4j
@Service
public class CjInfoServiceImpl extends ServiceImpl<CjInfoMapper, CjInfoBean> implements CjInfoService {

    //获取系统当前时间前一个小时的时间
    public String beforOneHourForDay(Date date) {
        Calendar calendar = Calendar.getInstance();
        calendar.setTime(date);
        calendar.add(Calendar.HOUR_OF_DAY, -1);
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        return sdf.format(calendar.getTime());
    }

    //获取系统当前时间
    public String nowtime(Date date) {
        Date nowtime = new Date();
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        return sdf.format(date);
    }

    @Override
    public List<CjInfoBean> getSelectAll() {
        CjInfoServiceImpl cj = new CjInfoServiceImpl();
        String beforonehourtime = cj.beforOneHourForDay(new Date());
        String nowtime = cj.nowtime(new Date());
        return baseMapper.getSelectAll(beforonehourtime, nowtime);
    }
//    public List<CjInfoBean> getSelectAll() {
//
//        return baseMapper.getSelectAll();
//    }

    @Override
    public List<CjInfoBean> getSelectSupp(String SAMPLENO) {

        return baseMapper.getSelectSupp(SAMPLENO);
    }

    @Override
    public void updateErrorCount(UpdParams updParams) {
        Integer result = baseMapper.updateErrorCount(updParams);
        log.info("result{}", result);
    }

    @Override
    public List<CjInfoBean> getSelectTime(UpdParams updParams) {
        return baseMapper.getSelectTime(updParams);
    }

    @Override
    public List<CjInfoBean> getSelecError() {
        return baseMapper.getSelecError();
    }

    @Override
    public void update(String SAMPLENO ,String BJCRZJHM ,String BJCRSJH) {
        Integer result = baseMapper.update(SAMPLENO,BJCRZJHM,BJCRSJH);
        log.info("result{}", result);
    }

}
